/**
 * @file       Char_test.cpp
 * @brief      TODO
 * @author     Huabo Zheng
 * @date       Jan 12, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */

#include "Char.h"
#include "gtest/gtest.h"
#include "errorcode.h"
namespace NS_LCD_AFW
{
class CChar_test: public ::testing::Test

{
public:
	virtual void SetUp()
	{
	}
	virtual void TearDown()
	{
	}
};
TEST_F(CChar_test,test_defualtConstruction)
{
	CChar *pChar = new CChar();
	EXPECT_TRUE(pChar->isHightlightable());
	EXPECT_TRUE(pChar->isFocusable());
	EXPECT_EQ(' ',pChar->getChar());
	OBJ_DESTORY(pChar);
}
TEST_F(CChar_test,test_setChar)
{
	CChar *pChar = new CChar();
	pChar->setChar('a');
	EXPECT_EQ('a',pChar->getChar());
	OBJ_DESTORY(pChar);
}
TEST_F(CChar_test,test_getChar)
{
	CChar *pChar = new CChar();
	pChar->setChar('a');
	EXPECT_EQ('a', pChar->getChar());
	OBJ_DESTORY(pChar);
}
TEST_F(CChar_test,test_onUpKeyPress)
{
	CFrame *pChar = new CChar();
	((CChar *)pChar)->setChar('a');
	EXPECT_EQ('a', ((CChar *)pChar)->getChar());
	EXPECT_EQ(ERR_SUCCESS,pChar->onUpKeyPress());
	EXPECT_EQ('b', ((CChar *)pChar)->getChar());
	EXPECT_EQ(ERR_SUCCESS,pChar->onUpKeyPress());
	EXPECT_EQ('c', ((CChar *)pChar)->getChar());
	OBJ_DESTORY(pChar);
}
TEST_F(CChar_test,test_onDownKeyPress)
{
	CFrame *pChar = new CChar();
	((CChar *) pChar)->setChar('c');
	EXPECT_EQ('c', ((CChar *)pChar)->getChar());
	EXPECT_EQ(ERR_SUCCESS, pChar->onDownKeyPress());
	EXPECT_EQ('b', ((CChar *)pChar)->getChar());
	EXPECT_EQ(ERR_SUCCESS, pChar->onDownKeyPress());
	EXPECT_EQ('a', ((CChar *)pChar)->getChar());
	OBJ_DESTORY(pChar);
}
TEST_F(CChar_test,test_onLeftKeyPress)
{
	CFrame *pChar = new CChar();
	EXPECT_EQ(ERR_EVENT_UN_HANDLED,pChar->onLeftKeyPress());
	EXPECT_FALSE(pChar->hasFocus());
	EXPECT_FALSE(pChar->isHightlight());
	OBJ_DESTORY(pChar);
}
TEST_F(CChar_test,test_onRightKeyPress)
{
	CFrame *pChar = new CChar();
	EXPECT_EQ(ERR_EVENT_UN_HANDLED,pChar->onRightKeyPress());
	EXPECT_FALSE(pChar->hasFocus());
	EXPECT_FALSE(pChar->isHightlight());
	OBJ_DESTORY(pChar);
}
TEST_F(CChar_test,test_onEnterKeyPress)
{
	CFrame *pChar = new CChar();
	EXPECT_EQ(ERR_EVENT_UN_HANDLED,pChar->onEnterKeyPress());
	EXPECT_FALSE(pChar->hasFocus());
	EXPECT_FALSE(pChar->isHightlight());
	OBJ_DESTORY(pChar);
}
TEST_F(CChar_test,test_onEscKeyPress)
{
	CFrame *pChar = new CChar();
	EXPECT_EQ(ERR_EVENT_UN_HANDLED,pChar->onEscKeyPress());
	EXPECT_FALSE(pChar->hasFocus());
	EXPECT_FALSE(pChar->isHightlight());
	OBJ_DESTORY(pChar);
}
TEST_F(CChar_test,test_onCreate)
{
	CChar *pChar = new CChar();
	EXPECT_EQ(ERR_SUCCESS,pChar->create("testChar",CRect(0,0,2,2)));
	EXPECT_EQ(CRect(0,0,1,1),pChar->getRect());
	OBJ_DESTORY(pChar);
}
} /* namespace NS_LCD_AFW */
